//
//  ViewController.m
//  CheckHttp
//
//  Created by 123456 on 2017/8/23.
//  Copyright © 2017年 zhuxin. All rights reserved.
//

#import "MainViewControllerDemo.h"
#import "ReportListViewControllerDemo.h"
#import "EcgHeader.h"
#import "IKCheckInterfaceDemo.h"
#import "EcgImageViewController.h"

@interface MainViewControllerDemo ()

@property (nonatomic, strong) UIButton *detectBtn;
@property (nonatomic, strong) UIButton *reportBtn;
@property (nonatomic, strong) UIButton *bpBtn;
@property (nonatomic, strong) UIButton *ecgImageBtn;
@property (nonatomic, strong) UIButton *ecgFielZipBtn;

@property (nonatomic, strong) UILabel *versionLabel;
@property (nonatomic, strong) IKCheckInterfaceDemo *checkInterfaceDemo;
@end

@implementation MainViewControllerDemo

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"心电检测";
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    self.navigationController.navigationBar.barTintColor = NAVIGATION_BAR_BG_COLOR;
    self.navigationController.navigationBar.backgroundColor = NAVIGATION_BAR_BG_COLOR;
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:NAVIGATION_BAR_TITLE_COLOR};
    self.navigationController.navigationBar.tintColor = NAVIGATION_BAR_BUTTON_COLOR;

    self.view.backgroundColor = [UIColor whiteColor];
    self.detectBtn = [[UIButton alloc] init];
    self.detectBtn.backgroundColor = ECG_COLOR_BACKGROUND;
    [self.detectBtn setTitle:@"心电实时检测" forState:UIControlStateNormal];
    [self.detectBtn setTitleColor:COLOR_BLACK_6F6F6F forState:UIControlStateNormal];
    [self.detectBtn addTarget:self action:@selector(onEcgRealtimeDetectBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    self.reportBtn = [[UIButton alloc] init];
    self.reportBtn.backgroundColor = ECG_COLOR_BACKGROUND;
    [self.reportBtn setTitleColor:COLOR_BLACK_6F6F6F forState:UIControlStateNormal];
    [self.reportBtn setTitle:@"心电报告回显" forState:UIControlStateNormal];
    [self.reportBtn addTarget:self action:@selector(onShowHistoryReportBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    self.ecgImageBtn = [[UIButton alloc] init];
    self.ecgImageBtn.backgroundColor = ECG_COLOR_BACKGROUND;
    [self.ecgImageBtn setTitleColor:COLOR_BLACK_6F6F6F forState:UIControlStateNormal];
    [self.ecgImageBtn setTitle:@"心电图片回显" forState:UIControlStateNormal];
    [self.ecgImageBtn addTarget:self action:@selector(onShowEcgImageView) forControlEvents:UIControlEventTouchUpInside];
    
    self.ecgFielZipBtn = [[UIButton alloc] init];
    self.ecgFielZipBtn.backgroundColor = ECG_COLOR_BACKGROUND;
    [self.ecgFielZipBtn setTitleColor:COLOR_BLACK_6F6F6F forState:UIControlStateNormal];
    [self.ecgFielZipBtn setTitle:@"心电文件压缩" forState:UIControlStateNormal];
    [self.ecgFielZipBtn addTarget:self action:@selector(onShowEcgFileZipView) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.versionLabel = [[UILabel alloc] init];
    self.versionLabel.textColor = COLOR_BLACK_6F6F6F;
    self.versionLabel.textAlignment = NSTextAlignmentCenter;
    
    
    [self.view addSubview:self.detectBtn];
    [self.view addSubview:self.reportBtn];
    [self.view addSubview:self.versionLabel];
    [self.view addSubview:self.ecgImageBtn];
//    [self.view addSubview:self.ecgFielZipBtn];
    
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
    self.versionLabel.text = [NSString stringWithFormat:@"SDK Demo V%@ build%@",app_Version,app_build];
    [self.detectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(@(CGSizeMake(160, 50)));
        make.centerX.equalTo(self.view);
        make.centerY.equalTo(self.view).offset(-100);
    }];
    
    [self.reportBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(@(CGSizeMake(160, 50)));
        make.centerX.equalTo(self.view);
        make.centerY.equalTo(self.view).offset(-40);
    }];
    
    [self.ecgImageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(@(CGSizeMake(160, 50)));
        make.centerX.equalTo(self.view);
        make.centerY.equalTo(self.view).offset(40);
    }];
    
//    [self.ecgFielZipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.size.equalTo(@(CGSizeMake(160, 50)));
//        make.centerX.equalTo(self.view);
//        make.top.equalTo(self.ecgImageBtn.mas_bottom).offset(20);
//    }];
    
    
    [self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.ecgImageBtn.mas_bottom).offset(30);
        make.centerX.equalTo(self.view);
    }];
    
    self.checkInterfaceDemo = [[IKCheckInterfaceDemo alloc] init];
}

//跳转到心电检测页面
- (void)onEcgRealtimeDetectBtnClick{
    IKEcgCheckController *controller = [IKEcgCheckController getInstance];
    [controller showEcgView:self.checkInterfaceDemo controller:self userData:@""];
}

//跳转到历史记录列表界面
- (void)onShowHistoryReportBtnClick{
    ReportListViewControllerDemo *hisVc = [ReportListViewControllerDemo new];
    hisVc.type = ReportListTypeResult;
    [self.navigationController pushViewController:hisVc animated:YES];
}

- (void)onShowEcgImageView{
    ReportListViewControllerDemo *hisVc = [ReportListViewControllerDemo new];
    hisVc.type = ReportListTypeImage;
    [self.navigationController pushViewController:hisVc animated:YES];
}

- (void)onShowEcgFileZipView{
    ReportListViewControllerDemo *hisVc = [ReportListViewControllerDemo new];
    hisVc.type = ReportListTypeZip;
    [self.navigationController pushViewController:hisVc animated:YES];
}

@end
